package cn.loveq.android.widget;

import android.app.Dialog;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import cn.loveq.android.R;
import cn.loveq.android.manager.SinaWeiboAuthorize;

public class CommentDialog extends Dialog implements
		android.view.View.OnClickListener {
	private Button cancel;
	private Button ok;
	private Context mContext;
	private EditText comment;
	private int WEIBO_MAX_LENGTH = 140;
	public CommentDialog(Context context, int theme) {
		super(context, theme);
		this.mContext = context;
		setContentView(R.layout.comment_dialog);
		cancel = (Button) findViewById(R.id.btn_comment_dialog_cancel);
		ok = (Button) findViewById(R.id.btn_comment_dialog_ok);
		comment = (EditText) findViewById(R.id.et_comment_dialog);
		comment.addTextChangedListener(new TextWatcher() {
			public void afterTextChanged(Editable s) {
			}

			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
			}

			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				String mText = comment.getText().toString();
				String mStr;
				int len = mText.length();
				if (len <= WEIBO_MAX_LENGTH) {
					len = WEIBO_MAX_LENGTH - len;
					// mTextNum.setTextColor(R.color.text_num_gray);
					if (!ok.isEnabled())
						ok.setEnabled(true);
				} else {
					len = len - WEIBO_MAX_LENGTH;
					if (ok.isEnabled())
						ok.setEnabled(false);
				}
			}
		});

		ok.setOnClickListener(this);
		cancel.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
	
	}

}
